package com.kaifamiao.demo.d0720;

import java.util.Random;

public class Demo01 {

    public static void main(String[] args) {
        double[] scores = new double[5];

        // 赋值
        for (int i = 0; i < scores.length; i ++){
            // 随机数 Random    Math.random() 0 ~ 1
            double score = (int)(Math.random() * 10000) / 100.0;
            scores[i] = score;
        }

        System.out.println("排序前： ");
        // 遍历输出
        for (int i = 0; i < scores.length; i ++){
            System.out.print(scores[i] + "\t");
        }

        // 排序  冒泡排序 降序
        for(int i = 0; i < scores.length - 1; i ++){ // 循环次数

            for(int j = 0; j < scores.length - 1 - i; j ++){

                if (scores[j] < scores[j + 1]){
                    double temp = scores[j + 1];
                    scores[j + 1] = scores[j];
                    scores[j] = temp;
                }
            }
        }



        System.out.println("\n排序后：");
        // 遍历输出
        for (int i = 0; i < scores.length; i ++){
            System.out.print(scores[i] + "\t");
        }
    }
}
